package com.igeek.shop.service;

import com.igeek.shop.dao.BaseDao;
import com.igeek.shop.entity.User;

public class LoginServiceImpl implements LoginService{

	private BaseDao<User> dao = new BaseDao<User>();
	
	
	public User getUser(User user) {
		String sql = "select * from user where username =? and password = ?";
		Object [] params = {user.getUsername(),user.getPassword()};
		Object userByOne = dao.getUserByOne(sql, params, new User());
		User returnUser = (User) userByOne;//null
		return returnUser;
		
	}

	@Override
	public User getUserByCookie(String userName) {
		String sql = "select * from user where username=?";
		Object [] params = {userName};
		Object userByOne = dao.getUserByOne(sql, params, new User());
		User returnUser = (User) userByOne;//null
		return returnUser;
	}

}
